package com.example.excel_upload.excel.controller;

import com.example.excel_upload.excel.service.ExcelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
public class ExcelController {

    @Autowired
    ExcelService excelService;

    @PostMapping("/api/add_student")
    public String addStudent(MultipartFile excel) {
        try {

            //调用excelService中的readExcel方法
            excelService.readExcel(excel);
        }catch (IOException e) {
            return e.getLocalizedMessage();
        }
        return "读取完成";
    }
}
